package com.shanzhi.connection.common;

import java.io.IOException;

public class ConvertDocxToMd {

    public static void convertToTempleFile(String imagesLoadPath, String inputFilePath, String outputFilePath) {
        try {
            ProcessBuilder processBuilder = new ProcessBuilder("pandoc", "--extract-media=" + imagesLoadPath, inputFilePath, "-t", "gfm", "-o", outputFilePath);
            processBuilder.inheritIO(); // 输出日志到控制台
            Process process = processBuilder.start();
            int exitCode = process.waitFor();

            if (exitCode == 0) {
                System.out.println("转换成功: " + outputFilePath);
            } else {
                System.err.println("转换失败，退出码: " + exitCode);
            }
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String input = "D:\\桌面\\成华组织\\AI问答文档(2)\\AI问答文档\\关于印发《成华区2025年“微网实格”治理关爱激励礼遇措施清单》的通知.docx";
        String output = "test.md";
        convertToTempleFile("images", input, output);
    }
}
